﻿using System;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x020003A8 RID: 936
[RequireComponent(typeof(Toggle))]
public class ItemChangeToggle : MonoBehaviour
{
	// Token: 0x17000244 RID: 580
	// (get) Token: 0x06001751 RID: 5969 RVA: 0x0009B94C File Offset: 0x00099B4C
	public Toggle toggle
	{
		get
		{
			if (this._toggle == null)
			{
				this._toggle = base.GetComponent<Toggle>();
			}
			return this._toggle;
		}
	}

	// Token: 0x17000245 RID: 581
	// (get) Token: 0x06001752 RID: 5970 RVA: 0x0009B974 File Offset: 0x00099B74
	// (set) Token: 0x06001753 RID: 5971 RVA: 0x0009B984 File Offset: 0x00099B84
	public bool interactable
	{
		get
		{
			return this.toggle.interactable;
		}
		set
		{
			this.toggle.interactable = value;
		}
	}

	// Token: 0x06001754 RID: 5972 RVA: 0x0009B994 File Offset: 0x00099B94
	public void Setup(string title, MoveableThumbnailSelectUI selectUI)
	{
		this.title.text = title;
		this.selectUI = selectUI;
		this.ApplyFromData(null);
	}

	// Token: 0x06001755 RID: 5973 RVA: 0x0009B9B0 File Offset: 0x00099BB0
	public void SetTitle(string title)
	{
		this.title.text = title;
	}

	// Token: 0x06001756 RID: 5974 RVA: 0x0009B9C0 File Offset: 0x00099BC0
	public void ApplyFromData(CustomSelectSet data)
	{
		if (!this.invoke)
		{
			return;
		}
		this.dataName.text = ((data == null) ? string.Empty : data.name);
		this.thumnbnailImage.sprite = ((data == null) ? null : data.thumbnail_S);
	}

	// Token: 0x06001757 RID: 5975 RVA: 0x0009BA18 File Offset: 0x00099C18
	public void OnSelectChange()
	{
		if (!this.invoke)
		{
			return;
		}
		CustomSelectSet selectedData = this.selectUI.GetSelectedData();
		this.dataName.text = ((selectedData == null) ? string.Empty : selectedData.name);
		this.thumnbnailImage.sprite = ((selectedData == null) ? null : selectedData.thumbnail_S);
	}

	// Token: 0x06001758 RID: 5976 RVA: 0x0009BA7C File Offset: 0x00099C7C
	public void ToggleSelectUI(bool flag)
	{
		if (!this.invoke)
		{
			return;
		}
		if (this.selectUI != null)
		{
			if (flag)
			{
				this.selectUI.Open(this._toggle);
			}
			else if (this.selectUI.openUI == this._toggle)
			{
				this.selectUI.Close();
			}
		}
	}

	// Token: 0x06001759 RID: 5977 RVA: 0x0009BAE8 File Offset: 0x00099CE8
	public void OnChangeState(MoveableUI.STATE state)
	{
		this.invoke = false;
		this.toggle.isOn = (state != MoveableUI.STATE.CLOSED);
		this.invoke = true;
	}

	// Token: 0x0600175A RID: 5978 RVA: 0x0009BB0C File Offset: 0x00099D0C
	private void OnDisable()
	{
		if (this.selectUI != null && this.selectUI.openUI == this._toggle)
		{
			this.selectUI.Close();
		}
		this.toggle.isOn = false;
	}

	// Token: 0x0600175B RID: 5979 RVA: 0x0009BB5C File Offset: 0x00099D5C
	private void Update()
	{
		if (this.toggle.isOn && this.selectUI.openUI != this._toggle)
		{
			this.invoke = false;
			this.toggle.isOn = false;
			this.invoke = true;
		}
	}

	// Token: 0x04001AFB RID: 6907
	private Color color;

	// Token: 0x04001AFC RID: 6908
	[SerializeField]
	private Text title;

	// Token: 0x04001AFD RID: 6909
	[SerializeField]
	private Image thumnbnailImage;

	// Token: 0x04001AFE RID: 6910
	[SerializeField]
	private Text dataName;

	// Token: 0x04001AFF RID: 6911
	[SerializeField]
	private MoveableThumbnailSelectUI selectUI;

	// Token: 0x04001B00 RID: 6912
	private bool invoke = true;

	// Token: 0x04001B01 RID: 6913
	public Action onDisable;

	// Token: 0x04001B02 RID: 6914
	private Toggle _toggle;
}
